
//人脸比对
function FaceComparisonEx() {
   
        //判断身份证头像信息是不是为空
        var data = "";
        var url = "http://127.0.0.1:38088/card=idcard";
        Ajax("POST", url, data, function gettingData(res) {
            if (res.code === "0") {
                Face1 = res.IDCardInfo.photoBase64;
                if (DevIndex == 1) {
                    var data = {
                        "filepath": "base64",  //"D://test11.jpg"  指定路径  "base64" 不保存本地，返回base64  ""   保存默认路径下     
                        "rotate": "0",      // 图像旋转角度，90的整数倍，默认："0"
                        "camidx": JSON.stringify(DevIndex),      // 摄像头索引，参数：0:主头；1:副头
                    };
                    var url = "http://127.0.0.1:38088/video=grabimage";
                    Ajax("get", url, JSON.stringify(data), function gettingData(res) {
                        if (res.code === "0") {
                            if (Face1 && res.photoBase64) {

                                var data = {
                                    "FaceOne": Face1,  // 图片1的base64数据，如人脸
                                    "FaceTwo": res.photoBase64    // 图片2的base64数据，如身份证头像
                                }
                                console.log(data);
                                var url = " http://127.0.0.1:38088/comparison=imgdata";
                                Ajax("POST", url, JSON.stringify(data), function gettingData(res) {
                                    console.log(res);
                                    if (res.code === "0") {
                                        log("相似度:" + res.data);
                                    }

                                })

                            }

                        } else {
                            log("获取现场图像失败");
                        }

                    }
                    )
                } else {
                    alert("请切换副头")
                }

            } else {
                log("身份证图像获取失败")
            }

        }
        );   
}


//读取火照
function ReadPassport(){
    var url =" http://127.0.0.1:38088/ReadPassport"
    var data = "";
    Ajax("POST", url, JSON.stringify(data), function gettingData(res) {
        if (res.code === "0") {
          log("护照读取成功")
		   var ojbdata = "ReadPassport <br />返回代码：" + res.code +
                "<br />返回信息：" + res.message +
			    "<br />CardType：" + res.passportinfo.CardType + 
                "<br />LastName：" + res.passportinfo.LastName +
				"<br />FirstName：" + res.passportinfo.FirstName +
				"<br />ChineseName：" + res.passportinfo.ChineseName +
                "<br />Gender：" + res.passportinfo.Gender +
                "<br />CardSerial：" + res.passportinfo.CardSerial +
                "<br />DataOfBirth：" + res.passportinfo.DataOfBirth +
                "<br />EffectiveDate：" + res.passportinfo.EffectiveDate +
                "<br />IssuingAuthority：" + res.passportinfo.IssuingAuthority +
                "<br />OptionalData：" + res.passportinfo.OptionalData +
                "<br />cMRZ1：" + res.passportinfo.cMRZ1 +
				"<br />cMRZ2：" + res.passportinfo.cMRZ2 +
                "<br />cMRZ3：" + res.passportinfo.cMRZ3 +
                "<br />BEEA：" + res.passportinfo.BEEA +
                "<br />Times：" + res.passportinfo.Times;
            log(ojbdata)
			addImgDiv(res.passportinfo.headImageBase64);
        } else {
            log("护照读取失败");
        }
    }
    );
}



// 活体检测
function Temperature(){
    var url =" http://127.0.0.1:38088/faceLive=start"
    var data={
        "time": "6"    // 超时次数
    }
    Ajax("POST", url, JSON.stringify(data), function gettingData(res) {
        if (res.code === "0") {
          log("检测结果:"+res.data+"---1:失败;0:图片;1:成功")
        } else {
            log("检测失败");
        }

    }
    );
}
// 活体检测 停止
function FaceLiveStop(){
    var url =" http://127.0.0.1:38088/faceLive=stop"
    var data = "";
    Ajax("POST", url, JSON.stringify(data), function gettingData(res) {
        if (res.code === "0") {
          log("停止检测成功")
        } else {
            log("停止检测失败");
        }
    }
    );
}